{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## SVM中使用多项式特征\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "from matplotlib import pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn import datasets\n",
    "X, y = datasets.make_moons()      #自动生成非线性的数据集"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-6.23489802e-01,  7.81831482e-01],\n",
       "       [-8.71318704e-01,  4.90717552e-01],\n",
       "       [ 1.40478334e+00, -4.14412623e-01],\n",
       "       [ 1.83808810e+00, -4.55349012e-02],\n",
       "       [ 0.00000000e+00,  5.00000000e-01],\n",
       "       [ 1.59599895e-01,  9.87181783e-01],\n",
       "       [ 3.20515776e-02,  9.99486216e-01],\n",
       "       [ 5.09442530e-02,  1.84891782e-01],\n",
       "       [-1.00000000e+00,  1.22464680e-16],\n",
       "       [ 6.72300890e-01,  7.40277997e-01],\n",
       "       [ 9.67294863e-01,  2.53654584e-01],\n",
       "       [-3.45365054e-01,  9.38468422e-01],\n",
       "       [-5.72116660e-01,  8.20172255e-01],\n",
       "       [ 1.57211666e+00, -3.20172255e-01],\n",
       "       [ 1.99794539e+00,  4.35929780e-01],\n",
       "       [-5.18392568e-01,  8.55142763e-01],\n",
       "       [ 1.76144596e+00, -1.48228395e-01],\n",
       "       [ 1.98155916e+00,  3.08841371e-01],\n",
       "       [ 5.72116660e-01,  8.20172255e-01],\n",
       "       [ 8.40400105e-01, -4.87181783e-01],\n",
       "       [ 3.27699110e-01, -2.40277997e-01],\n",
       "       [ 9.26916757e-01,  3.75267005e-01],\n",
       "       [ 3.27051370e-02,  2.46345416e-01],\n",
       "       [ 9.90311321e-02,  6.61162609e-02],\n",
       "       [ 3.45365054e-01,  9.38468422e-01],\n",
       "       [-9.91790014e-01,  1.27877162e-01],\n",
       "       [ 1.28452759e+00, -4.58667853e-01],\n",
       "       [ 6.23489802e-01,  7.81831482e-01],\n",
       "       [ 1.00000000e+00,  0.00000000e+00],\n",
       "       [ 7.61445958e-01,  6.48228395e-01],\n",
       "       [-1.59599895e-01,  9.87181783e-01],\n",
       "       [ 2.22520934e-01,  9.74927912e-01],\n",
       "       [ 4.62538290e-01,  8.86599306e-01],\n",
       "       [ 1.67230089e+00, -2.40277997e-01],\n",
       "       [ 4.27883340e-01, -3.20172255e-01],\n",
       "       [ 1.98586378e-01, -9.81105305e-02],\n",
       "       [ 1.34536505e+00, -4.38468422e-01],\n",
       "       [-9.67294863e-01,  2.53654584e-01],\n",
       "       [ 8.01413622e-01,  5.98110530e-01],\n",
       "       [ 9.49055747e-01,  3.15108218e-01],\n",
       "       [-4.62538290e-01,  8.86599306e-01],\n",
       "       [ 1.09602303e+00, -4.95379113e-01],\n",
       "       [ 1.90096887e+00,  6.61162609e-02],\n",
       "       [-8.38088105e-01,  5.45534901e-01],\n",
       "       [ 9.91790014e-01,  1.27877162e-01],\n",
       "       [ 2.81650650e-01, -1.95682551e-01],\n",
       "       [-2.22520934e-01,  9.74927912e-01],\n",
       "       [-6.72300890e-01,  7.40277997e-01],\n",
       "       [ 6.54634946e-01, -4.38468422e-01],\n",
       "       [-8.01413622e-01,  5.98110530e-01],\n",
       "       [-9.81559157e-01,  1.91158629e-01],\n",
       "       [ 1.62348980e+00, -2.81831482e-01],\n",
       "       [ 1.51839257e+00, -3.55142763e-01],\n",
       "       [ 2.38554042e-01, -1.48228395e-01],\n",
       "       [ 1.61911895e-01, -4.55349012e-02],\n",
       "       [ 7.18349350e-01,  6.95682551e-01],\n",
       "       [ 1.87131870e+00,  9.28244800e-03],\n",
       "       [-9.26916757e-01,  3.75267005e-01],\n",
       "       [ 8.38088105e-01,  5.45534901e-01],\n",
       "       [-3.20515776e-02,  9.99486216e-01],\n",
       "       [ 2.05460725e-03,  4.35929780e-01],\n",
       "       [-9.60230259e-02,  9.95379113e-01],\n",
       "       [ 8.71318704e-01,  4.90717552e-01],\n",
       "       [ 1.99179001e+00,  3.72122838e-01],\n",
       "       [-7.61445958e-01,  6.48228395e-01],\n",
       "       [ 1.94905575e+00,  1.84891782e-01],\n",
       "       [ 1.22252093e+00, -4.74927912e-01],\n",
       "       [ 1.28681296e-01,  9.28244800e-03],\n",
       "       [ 1.71834935e+00, -1.95682551e-01],\n",
       "       [ 2.00000000e+00,  5.00000000e-01],\n",
       "       [ 5.18392568e-01,  8.55142763e-01],\n",
       "       [ 1.92691676e+00,  1.24732995e-01],\n",
       "       [ 1.84408430e-02,  3.08841371e-01],\n",
       "       [-9.00968868e-01,  4.33883739e-01],\n",
       "       [ 9.00968868e-01,  4.33883739e-01],\n",
       "       [ 5.95216657e-01, -4.14412623e-01],\n",
       "       [ 2.84527587e-01,  9.58667853e-01],\n",
       "       [ 7.15472413e-01, -4.58667853e-01],\n",
       "       [ 7.30832427e-02,  1.24732995e-01],\n",
       "       [ 8.20998618e-03,  3.72122838e-01],\n",
       "       [ 7.77479066e-01, -4.74927912e-01],\n",
       "       [-7.18349350e-01,  6.95682551e-01],\n",
       "       [-2.84527587e-01,  9.58667853e-01],\n",
       "       [ 1.80141362e+00, -9.81105305e-02],\n",
       "       [ 1.03205158e+00, -4.99486216e-01],\n",
       "       [ 9.03976974e-01, -4.95379113e-01],\n",
       "       [ 4.04783343e-01,  9.14412623e-01],\n",
       "       [ 1.15959990e+00, -4.87181783e-01],\n",
       "       [ 9.97945393e-01,  6.40702200e-02],\n",
       "       [ 4.81607432e-01, -3.55142763e-01],\n",
       "       [ 9.81559157e-01,  1.91158629e-01],\n",
       "       [-4.04783343e-01,  9.14412623e-01],\n",
       "       [ 9.67948422e-01, -4.99486216e-01],\n",
       "       [ 5.37461710e-01, -3.86599306e-01],\n",
       "       [-9.97945393e-01,  6.40702200e-02],\n",
       "       [-9.49055747e-01,  3.15108218e-01],\n",
       "       [ 9.60230259e-02,  9.95379113e-01],\n",
       "       [ 1.46253829e+00, -3.86599306e-01],\n",
       "       [ 1.96729486e+00,  2.46345416e-01],\n",
       "       [ 3.76510198e-01, -2.81831482e-01]])"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0,\n",
       "       1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0,\n",
       "       0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1,\n",
       "       1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1,\n",
       "       0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1], dtype=int64)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PathCollection at 0xaeadd77b48>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAD4CAYAAADvsV2wAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAdy0lEQVR4nO3df5BddX3/8ec7mw1sq2bBrAqbpInTVItAjezE2nzbokEMTCEUF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xcCsXy5mdpyZHRPdXgKsBb6bWwuTdfP+tm7f+4CdHh2pCsic29GWUz2XRi62jMaBX4sqQ34W2N9MKZaJmb2heSzIzNbQiG/Pdf5f+Yva+JfA4+7+fxMW689nUvQR64yPfv8yjW/GHwHPAHdGj58I7Gg7Av59GnvDnyi63THb8VrgLuDJ6O/x0eNjwE3R7Z8DHqFRPfIIcGnR7e70/gKbgXOj28cCXwB2Af8GvLHoNs9zO64GHos+g7uBNxfd5oTtuBXYCxyMxselwIeBD0fPG3BjtJ2PkFDhVvS/Lrbj8pbP4x7g54puc8J2/B8a6ZmHgQejf2fn8ZloagURkZqoY0pHRKSWFPBFRGpCAV9EpCYU8EVEakIBX0SkJhTwRURqQgFfRKQm/hc815SSpymo4gAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(X[y==0,0], X[y==0,1]) #moon形状\n",
    "plt.scatter(X[y==1,0], X[y==1,1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PathCollection at 0xaeade45288>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAD4CAYAAADhNOGaAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nO3dfbBdVZnn8e+PGDQ99iThRYWEK1DD4CuCfQdsmeqWFwHtasP4QoPjGKuwUlTrOGNXU8ayC63YU0atbnussbuNimJXD4ioGBUHMdGxRkW5NDEBHSRAK3kZSYtJ65AJITzzx9kXzj337P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5KPad9DFKWrwDXR8QhSVfRqs2cP/GSjSalczuIf6A1V85vJL0auBk4reIyIemZwBeA/xwR/9y5u8tLkjvHDgRtIuLCMf/ELqD9DnA1sGfMv5mrV3kl/ULSCRGxN6uKPpzzN/Zkvx+Q9G1adzVlBYJBztf8MbskPQ1YTnXNB33LGxG/bHv6CeCDJZRrVKV+XsfVfpGNiFsk/bWk4yKissndJC2lFQT+PiK+2OWQWpxjNw0V6w7gNEmnSDqaVudm6Zk4mc3A2uzxWmBRjUbSSklPzx4fB5wL/Li0Eg52vtr/Ha8HtkbWC1eBvuXtaP99Da1241RtBt6cZba8DDgw35yYIknPme8fknQ2revXL3u/aqLlEfAp4CcR8Zc5h9XjHFfdW12XH+Df0Yruh4BfALdm208Ebmk77tW0sgfup9WkVFV5jwW2APdlv4/Jts8Cn8wevxzYQSv7ZQdwZQXlXHS+gA3Aa7LHzwA+D+wEfgicWvHnoF95PwDck53TbwHPq7Cs1wN7gcPZZ/dK4Crgqmy/gI9l/5Yd5GTDJVTet7ed29uBl1dc3n9Lq5lnO7At+3l1yuc478dTTJiZNZybhszMGs6BwMys4RwIzMwazoHAzKzhHAjMzBrOgcDMrOEcCMzMGu7/A8wmoSM0XtHFAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "X, y = datasets.make_moons(noise=0.15, random_state=666) #添加噪音（增加标准差），带上随机种子\n",
    "plt.scatter(X[y==0,0], X[y==0,1])\n",
    "plt.scatter(X[y==1,0], X[y==1,1])             #非线性"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 使用多项式特征的SVM"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.preprocessing import PolynomialFeatures, StandardScaler      #需要标准化\n",
    "from sklearn.svm import LinearSVC\n",
    "from sklearn.pipeline import Pipeline              #需要顺序执行\n",
    "\n",
    "def PolynomialSVC(degree, C=1.0):\n",
    "    return Pipeline([\n",
    "        (\"poly\", PolynomialFeatures(degree=degree)),  #生成多项式特征\n",
    "        (\"std_scaler\", StandardScaler()),             #标准化\n",
    "        (\"linearSVC\", LinearSVC(C=C))                 #调用SVM\n",
    "    ])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Pipeline(memory=None,\n",
       "         steps=[('poly',\n",
       "                 PolynomialFeatures(degree=3, include_bias=True,\n",
       "                                    interaction_only=False, order='C')),\n",
       "                ('std_scaler',\n",
       "                 StandardScaler(copy=True, with_mean=True, with_std=True)),\n",
       "                ('linearSVC',\n",
       "                 LinearSVC(C=1.0, class_weight=None, dual=True,\n",
       "                           fit_intercept=True, intercept_scaling=1,\n",
       "                           loss='squared_hinge', max_iter=1000,\n",
       "                           multi_class='ovr', penalty='l2', random_state=None,\n",
       "                           tol=0.0001, verbose=0))],\n",
       "         verbose=False)"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "poly_svc = PolynomialSVC(degree=3)\n",
    "poly_svc.fit(X, y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "def plot_decision_boundary(model, axis):\n",
    "    \n",
    "    x0, x1 = np.meshgrid(\n",
    "        np.linspace(axis[0], axis[1], int((axis[1]-axis[0])*100)).reshape(-1, 1),\n",
    "        np.linspace(axis[2], axis[3], int((axis[3]-axis[2])*100)).reshape(-1, 1),\n",
    "    )\n",
    "    X_new = np.c_[x0.ravel(), x1.ravel()]\n",
    "\n",
    "    y_predict = model.predict(X_new)\n",
    "    zz = y_predict.reshape(x0.shape)\n",
    "\n",
    "    from matplotlib.colors import ListedColormap\n",
    "    custom_cmap = ListedColormap(['#EF9A9A','#FFF59D','#90CAF9'])\n",
    "    \n",
    "    plt.contourf(x0, x1, zz, cmap=custom_cmap)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PathCollection at 0xaeae0962c8>"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYQAAAD8CAYAAAB3u9PLAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nO3df5Ac5Z3f8fdXKx1a4xWLDDpkCZCxgRhMIhmKs0+phOLwxZJT4MvJOWypTqbsqJwcIBeVKnPRFZeiioq5VFElsC+OzmdODpR/REl8XCwVh4wdp5TgmJ8WCydZUMastLb4cZLW9spoV0/+mB4xGrpnumee7n66+/Oq2tLsTO/2o96Z/j4/vs/zmHMOERGReWUXQEREwqCAICIigAKCiIhEFBBERARQQBARkYgCgoiIAJ4Cgpl9xcwOm9mzCa9fY2ZHzezp6OsOH+cVERF/5nv6PX8FfAH4ao9j/rdz7p97Op+IiHjmpYXgnPs+8LqP3yUiIuXw1UJI44Nm9gxwCPi3zrmJ7gPMbBOwCeDMM8648uLzziuweCJStNdG31F2EWrn5b978lXn3LmD/GxRAeFJ4ELn3C/MbC3wLeDi7oOcc9uAbQCrVqxw392ypaDiiUjRxtePsHViQ9nFqJ3PXn3GS4P+bCFZRs65Y865X0SPdwILzOycIs4tIiLpFBIQzOw8M7Po8dXReV8r4twiIpKOly4jM/sacA1wjplNAn8KLABwzn0JWAf8azObBWaAG52WWRURCYqXgOCc+3if179AKy1VRARA4wcB0kxlEREBFBBERCSigCAiIoACgoiIRBQQREQEUEAQkRKMrx8puwgSQwFBRAqnlNMwKSCIiAiggCAiIhEFBBERARQQREQkooA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hVzgy/5oLoel4EPGpme51zL/gpYaI016eQa9hHmjL8DfA159yvzewztFo11+ZesmxCuJZpPAlc6Jz7hZmtBb4FXFxGQczs7cB/Az7rnDvW/XLMj5RyPfuUM/P1LDQguOGXwcA5dyj697CZ/Q9azXqvAcFDOQtZrqNXOc3s52a21Dk3FTVnDyf8jvb1fNHMvkerppF3QEhzfdrHTJrZfOAsiu9u6FtO59xrHd/+BXB3AeXKqhLLx3Te0JxzO83sz83sHOdcoQvKmdkCWjfZB51z/z3mkCCuZ79yDnI9K9VlZGZnmtlY+zHwu7T2ZAhNCMt1PARsjB5vBN7SsjGzs83sjOjxOcBqilmWPM316Sz/OuBRF42UFahvObv6jq+n1ZcbmoeAP4yyYz4AHG13J4bEzM5rjxOZ2dW07k+v9f4p72Uw4DKsEGUAAADtSURBVC+B551z9yQcVvr1TFPOga5n0aPjPUbNf49W5P018HPg4ej5dwI7o8cX0cr0eAaYoNWFE1w53ZuZCPtp1bbLKOc7gO8AP47+XRw9fxXw5ejxbwN7o+u5F/hUgeV7y/UB7gSujx4vBP4rcAD4f8BFJb0v+5XzP0TvxWeA7wL/oIQyfg2YAk5E781PAZ8BPhO9brQ2qXoh+jsnZvGVXM6bO67lY8Bvl1DGf0yr++dHwNPR19rQrmfKcma+nlq6QkREgIp1GYmISH4UEEREBFBAEBGRiAKCiIgACggiIhJRQBAREUABQUREIv8fswQLosKOqxYAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plot_decision_boundary(poly_svc, axis=[-1.5, 2.5, -1.0, 1.5])\n",
    "plt.scatter(X[y==0,0], X[y==0,1])\n",
    "plt.scatter(X[y==1,0], X[y==1,1])  #多项式特征的形式来处理非线性边界"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 使用多项式核函数的SVM"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.svm import SVC                                  #直接使用SVM\n",
    "def PolynomialKernelSVC(degree, C=1.0):                       #  核\n",
    "    return Pipeline([\n",
    "        (\"std_scaler\", StandardScaler()),\n",
    "        (\"kernelSVC\", SVC(kernel=\"poly\", degree=degree, C=C))\n",
    "    ])                                                         #自动使用多项式特征，再SVM"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Pipeline(memory=None,\n",
       "         steps=[('std_scaler',\n",
       "                 StandardScaler(copy=True, with_mean=True, with_std=True)),\n",
       "                ('kernelSVC',\n",
       "                 SVC(C=1.0, break_ties=False, cache_size=200, class_weight=None,\n",
       "                     coef0=0.0, decision_function_shape='ovr', degree=3,\n",
       "                     gamma='scale', kernel='poly', max_iter=-1,\n",
       "                     probability=False, random_state=None, shrinking=True,\n",
       "                     tol=0.001, verbose=False))],\n",
       "         verbose=False)"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "poly_kernel_svc = PolynomialKernelSVC(degree=3)\n",
    "poly_kernel_svc.fit(X, y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PathCollection at 0xaeaf681548>"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYQAAAD8CAYAAAB3u9PLAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAf2klEQVR4nO3df5Bd5X3f8fdXuzJakwUhC4WNhJAJPyICLQINjqM6pQ5OLTmDklieYqtTzNijcVO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fci1PAkvNbKKY1v1MinaWzjk35Zx7Ono8TSszcmXXYaV/ninbmVkwASEDB/y1mX03KnURorhyHUN/szL6eefcFLR+eIAVCcctMbOnzOxJMysqaKT5fOaPca3U5RPAOwppXUwbIknfxw9GUwe7zOzimNfLFsLPY1rvNrNnzewhM/vlMhsSTVOuA77d9VJQn2ePdkLGz7OIWkbzPJTBANjgnHvZzFYAj5jZ30Q9D2+KLNcxjF7tzPA2q6PP81LgUTN7zjn3gp8WJkrz+RTyGfaRpg1/BXzZOfdTM/sErVHNe3NvWTYhfJZpPA1c4px708w2AV8HLi+jIWb2c8DXgE865052vxzzT0r5PPu0M/PnWWhAcMOXwcA593L093Ez+1+0hvVeA4KHdhZSrqNXO83sx2Y24ZybioazxxPeo/15vmhmj9PqaeQdENJ8Pu1jJs1sFDif4qcb+rbTOfdax5d/AnymgHZlVYnyMZ0XNOfcHjP7L2a23DlXaEE5M1tM6yL7P5xzfxFzSBCfZ792DvJ5VmrKyMzONbPx9mPgN2jdkyE0IZTr2A3cGj2+FThrZGNmF5jZOdHj5cAGiilLnubz6Wz/FuBRF62UFahvO7vmjm+mNZcbmt3Av4iyY34FONGeTgyJmV3UXicysxtoXZ9e6/2vvLfBgD8FDjrn7kk4rPTPM007B/o8i14d77Fq/tu0Iu9PgR8DD0fP/wKwJ3p8Ka1Mj2eBA7SmcIJrp/tZJsJhWr3tMtr5DuCbwA+iv5dFz68H7o8e/yrwXPR5Pgd8rMD2nfX5AHcDN0ePlwD/EzgC/D/g0pJ+Lvu18w+jn8VngceAXyqhjV8GpoDZ6GfzY8AngE9Erxutm1S9EH2fE7P4Sm7n7R2f5ZPAr5bQxn9Ea/rn+8Az0Z9NoX2eKduZ+fNU6QoREQEqNmUkIiL5UUAQERFAAUFERCIKCCIiAiggiIhIRAFBREQABQQREYn8f/oq42RZc5GcAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plot_decision_boundary(poly_kernel_svc, axis=[-1.5, 2.5, -1.0, 1.5])\n",
    "plt.scatter(X[y==0,0], X[y==0,1])\n",
    "plt.scatter(X[y==1,0], X[y==1,1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
